#include "compiler.h"

LINKED_LIST(1, char *);
LINKED_LIST_STRUCT(1) *args_incl = 0;

struct options args;

static void args_set(char *what, char v) 
{
	if (strcmp(what, "O") == 0) {
		args.optimization = v;
	} else if (strcmp(what, "V") == 0) {
		args.verbose = v;
	} else {
		ERROR("Unknown option '%s'", what, ERROR_ARGS);
	}
}

void args_on(char *what)
{
	args_set(what, 1);
}

void args_off(char *what)
{
	args_set(what, 0);
}

void args_switch(char *what)
{
	if (what[0] == 'I') {
		LINKED_LIST_ADD(1, args_incl, what+1);
	} else {
		ERROR("Unknown option '%s'", what, ERROR_ARGS);
	}
}

void args_init()
{
	args_set("O", 0);
	args_set("V", 0);
	LINKED_LIST_ADD(1, args_incl, ".");
}